//
//  MyorderViewModel.m
//  LoveFreshBeen
//
//  Created by vinsent on 16/10/16.
//  Copyright © 2016年 魏根. All rights reserved.
//

#import "MyorderViewModel.h"
#import "NetWorkingTool.h"
#import <YYModel.h>


@implementation MyorderViewModel

+ (instancetype) sharedMyorder {
    
    static MyorderViewModel *instance;
    static dispatch_once_t onceToken;
    dispatch_once(&onceToken, ^{
        instance = [[MyorderViewModel alloc] init];
    });
    return instance;
}



- (void)loadMyorderDataWithFinished:(void (^)(BOOL succes))finished {
    
    NSString *urlString = [NetWorkingTool shareInstance].params[@"13"];
    
    
    [NetWorkingTool postUrlString:urlString withParam:@{@"call" : @13} withSuccessBlock:^(id data) {
        
        NSArray *responsobjct = data[@"data"];
        
        NSMutableArray *mArr = [NSMutableArray array];
        for (NSDictionary *dict in responsobjct) {
           
                Myorder *myorderModel = [[Myorder alloc] init];
                [myorderModel yy_modelSetWithDictionary:dict];
                OrderViewModel *orderViewM = [[OrderViewModel alloc] init];
                orderViewM.myorderModel = myorderModel;
                [mArr addObject:orderViewM];      
        }

        self.myorders = [mArr copy];
        finished(YES);
        
    } withFailedBlock:^(NSError *error) {
        
        
    } withErrorBlock:^(NSString *message) {
        
        
    }];
    
}
@end
